package dolf.objects;
import dolf.game.*;
import dolf.objects.WorldObject;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.util.LinkedList;
import java.util.List;
public class Ball extends CircleObject implements java.io.Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Color color;
	private Player player;
	private boolean moved;
	private List<WorldObject> collitedWith;
	private static final int BALL_SIZE = 7;
	private transient java.awt.Image overlay;
	
	public Ball(Point pos, Color col, Player player){
		super(pos, BALL_SIZE, true);
		this.player = player;
		//this.setRadius(BALL_SIZE);
		//this.setPosition(pos);
		this.color = col;
		this.direc = new Vector(0,0);
		collitedWith = new LinkedList<WorldObject>();
		this.setMass(2);
		
		overlay = ImageStore.getInstance().getImage("dolf/gfx/environment/ball_overlay.png");
		overlay = overlay.getScaledInstance(2*this.getRadius(), 2*this.getRadius(), Image.SCALE_SMOOTH);
	}
	public void setColor(Color col){
		color = col;
	}
	public Color getColor(){
		return color;
	}
	public void setMoved(boolean bool){
		this.moved = bool;
	}
	public boolean getMoved(){
		return this.moved;
	}
	public void paint(Graphics2D g){
		Color tmp = g.getColor();
		g.setColor(color);
		g.fillOval(this.getPosition().getIntX() - this.getRadius(), this.getPosition().getIntY() - this.getRadius(), 2*this.getRadius(),2*this.getRadius());
		if (overlay == null) {
	       	overlay = ImageStore.getInstance().getImage("dolf/gfx/environment/ball_overlay.png");
	    	overlay = overlay.getScaledInstance(2*this.getRadius(), 2*this.getRadius(), Image.SCALE_SMOOTH);
	    }
		g.drawImage(overlay, this.getPosition().getIntX()-this.getRadius(), this.getPosition().getIntY()-this.getRadius(), 2*this.getRadius(), 2*this.getRadius(),null);
		g.setColor(tmp);
	}
	public List<WorldObject> getCollList(){
		return collitedWith;
	} 
	public void addCollition(WorldObject obj){
		collitedWith.add(obj);
	}
	public void clearCollition(){
		collitedWith.clear();
	}
	public Player getPlayer(){
		return this.player;
	}
	public void setPlayer(Player player){
		this.player = player;
	}

}
